.class public final Lcom/baidu/crabsdk/b/s;
.super Ljava/lang/Object;


# static fields
.field private static bi:Landroid/content/SharedPreferences;

.field private static mContext:Landroid/content/Context;


# direct methods
.method public static M()Ljava/lang/String;
    .locals 4

    sget-object v0, Lcom/baidu/crabsdk/a;->c:Ljava/lang/String;

    invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-nez v0, :cond_0

    new-instance v0, Ljava/lang/StringBuilder;

    const-string v1, "uid is which user setted "

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    sget-object v1, Lcom/baidu/crabsdk/a;->c:Ljava/lang/String;

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/baidu/crabsdk/c/a;->s(Ljava/lang/String;)I

    sget-object v0, Lcom/baidu/crabsdk/a;->c:Ljava/lang/String;

    return-object v0

    :cond_0
    sget-object v0, Lcom/baidu/crabsdk/b/s;->mContext:Landroid/content/Context;

    if-nez v0, :cond_1

    const-string v0, "get SharedPreferences error because context is null for unknown reasons!!!"

    invoke-static {v0}, Lcom/baidu/crabsdk/c/a;->v(Ljava/lang/String;)I

    const-string v0, "N/A"

    return-object v0

    :cond_1
    sget-object v1, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    const/4 v2, 0x0

    if-nez v1, :cond_2

    const-string v1, "crab_user_info"

    invoke-virtual {v0, v1, v2}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v0

    sput-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    :cond_2
    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    const-string v1, "userId"

    const-string v3, ""

    invoke-interface {v0, v1, v3}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v3

    if-eqz v3, :cond_3

    invoke-static {}, Ljava/util/UUID;->randomUUID()Ljava/util/UUID;

    move-result-object v0

    invoke-virtual {v0}, Ljava/util/UUID;->toString()Ljava/lang/String;

    move-result-object v0

    sget-object v3, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    invoke-interface {v3}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v3

    invoke-interface {v3, v1, v0}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    move-result-object v1

    invoke-static {v1, v2}, Lcom/baidu/crabsdk/c/c;->a(Landroid/content/SharedPreferences$Editor;Z)V

    :cond_3
    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "uid is UUID "

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Lcom/baidu/crabsdk/c/a;->s(Ljava/lang/String;)I

    return-object v0
.end method

.method public static N()Ljava/util/HashMap;
    .locals 5
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/HashMap<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    sget-object v1, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    if-eqz v1, :cond_0

    const-string v2, "users_custom"

    const-string v3, ""

    invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v2

    if-nez v2, :cond_0

    :try_start_0
    new-instance v2, Lorg/json/JSONObject;

    invoke-direct {v2, v1}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2}, Lorg/json/JSONObject;->keys()Ljava/util/Iterator;

    move-result-object v1

    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_0

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    invoke-virtual {v2, v3}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v0, v3, v4}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception v1

    invoke-virtual {v1}, Lorg/json/JSONException;->printStackTrace()V

    :cond_0
    return-object v0
.end method

.method public static O()Ljava/lang/String;
    .locals 3

    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    const-string v1, ""

    if-eqz v0, :cond_0

    const-string v2, "users_custom"

    invoke-interface {v0, v2, v1}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    return-object v0

    :cond_0
    return-object v1
.end method

.method public static a(Ljava/util/HashMap;)V
    .locals 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/HashMap<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;)V"
        }
    .end annotation

    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    const/4 v1, 0x0

    const-string v2, "users_custom"

    if-eqz v0, :cond_0

    if-eqz p0, :cond_0

    :try_start_0
    invoke-static {p0}, Lcom/baidu/crabsdk/sender/g;->b(Ljava/util/Map;)Ljava/lang/String;

    move-result-object p0

    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v0

    invoke-interface {v0, v2, p0}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    move-result-object p0

    invoke-static {p0, v1}, Lcom/baidu/crabsdk/c/c;->a(Landroid/content/SharedPreferences$Editor;Z)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    return-void

    :catch_0
    move-exception p0

    invoke-virtual {p0}, Ljava/lang/Exception;->printStackTrace()V

    return-void

    :cond_0
    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    if-eqz v0, :cond_1

    if-nez p0, :cond_1

    invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object p0

    const-string v0, ""

    invoke-interface {p0, v2, v0}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    move-result-object p0

    invoke-static {p0, v1}, Lcom/baidu/crabsdk/c/c;->a(Landroid/content/SharedPreferences$Editor;Z)V

    :cond_1
    return-void
.end method

.method public static c(Ljava/lang/String;)V
    .locals 3

    sput-object p0, Lcom/baidu/crabsdk/a;->c:Ljava/lang/String;

    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    const/4 v1, 0x0

    if-nez v0, :cond_0

    sget-object v0, Lcom/baidu/crabsdk/b/s;->mContext:Landroid/content/Context;

    if-eqz v0, :cond_0

    const-string v2, "crab_user_info"

    invoke-virtual {v0, v2, v1}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v0

    sput-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    :cond_0
    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    if-eqz v0, :cond_1

    invoke-static {p0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-nez v0, :cond_1

    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v0

    const-string v2, "userId"

    invoke-interface {v0, v2, p0}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    move-result-object p0

    invoke-static {p0, v1}, Lcom/baidu/crabsdk/c/c;->a(Landroid/content/SharedPreferences$Editor;Z)V

    :cond_1
    return-void
.end method

.method public static d(Landroid/content/Context;)V
    .locals 2

    sget-object v0, Lcom/baidu/crabsdk/b/s;->mContext:Landroid/content/Context;

    if-nez v0, :cond_0

    sput-object p0, Lcom/baidu/crabsdk/b/s;->mContext:Landroid/content/Context;

    const/4 v0, 0x0

    const-string v1, "crab_user_info"

    invoke-virtual {p0, v1, v0}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object p0

    sput-object p0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    :cond_0
    return-void
.end method

.method public static getUserName()Ljava/lang/String;
    .locals 3

    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    const-string v1, ""

    if-eqz v0, :cond_0

    const-string v2, "userName"

    invoke-interface {v0, v2, v1}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    return-object v0

    :cond_0
    return-object v1
.end method

.method public static setUserName(Ljava/lang/String;)V
    .locals 2

    sget-object v0, Lcom/baidu/crabsdk/b/s;->bi:Landroid/content/SharedPreferences;

    if-eqz v0, :cond_0

    invoke-interface {v0}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v0

    const-string v1, "userName"

    invoke-interface {v0, v1, p0}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    move-result-object p0

    const/4 v0, 0x0

    invoke-static {p0, v0}, Lcom/baidu/crabsdk/c/c;->a(Landroid/content/SharedPreferences$Editor;Z)V

    :cond_0
    return-void
.end method
